#include "app_adc.h"

/***************************************************************************************************
 * variable definition
 **************************************************************************************************/

// 105
volatile uint32_t ADC_APTHP1 = 0;
// 106
volatile uint32_t ADC_APTHT1 = 0;    
// 108
volatile uint32_t ADC_APTLP = 0;
// 109
volatile uint32_t ADC_APTLT = 0;      
// 111
volatile uint32_t ADC_APTHP2 = 0;
// 112
volatile uint32_t ADC_APTHT2 = 0;

volatile uint32_t ADC_MODEVF = 0;

volatile uint32_t ADC_VBUS = 0;

// 114
volatile uint32_t ADC_ATEM = 0;
// 101
volatile uint32_t ADC_RTEM = 0;

volatile uint32_t syscoun;

/***************************************************************************************************
 * function declaration
 **************************************************************************************************/


/***************************************************************************************************
 * Scheduling function definition
 ***************************************************************************************************/
 
 void app_adcInit() {

    INT_SYS_SetPriority(ADC0_IRQn, 0);                 
    INT_SYS_EnableIRQ(ADC0_IRQn);

    ADC_DRV_Start(0);
}
 
/*此中断1/16MS进入一次，即：62.5us*/
void ADC0_IRQHandler()
{
    
    ADC_DRV_ClearEoseqFlagCmd(0);    
    
    syscoun++;
    
    ADC_APTHP1  = ADC0->FIFO & 0xFFF;
    ADC_APTHT1  = ADC0->FIFO & 0xFFF; 
    ADC_APTLP   = ADC0->FIFO & 0xFFF;
    ADC_APTLT   = ADC0->FIFO & 0xFFF;     
    ADC_APTHP2  = ADC0->FIFO & 0xFFF;
    ADC_APTHT2  = ADC0->FIFO & 0xFFF;    
    ADC_MODEVF  = ADC0->FIFO & 0xFFF;
    ADC_VBUS  = ADC0->FIFO & 0xFFF;  
    
   
}

